function getFontSize() {
  return Number(String(document.documentElement.style.fontSize).replace('px', ''));
}

//通过日期取星期
function toWeekName(date) {
  let newDate = new Date(date.replace(/-/g, '/'));
  return {num: newDate.getDay(), text: toWeekNameByNum(newDate.getDay())};
}

//通过数字取星期
function toWeekNameByNum(num) {
  let weekday = new Array(7);
  weekday[0] = "周日";
  weekday[1] = "周一";
  weekday[2] = "周二";
  weekday[3] = "周三";
  weekday[4] = "周四";
  weekday[5] = "周五";
  weekday[6] = "周六";
  return weekday[num];
}

function getWeekStartAndEnd() {
  //设置默认时间
  var monday = new Date(),
    sunday,
    day = monday.getDay(), //星期
    date = monday.getDate(); //日期
  switch (day) {
    case 1:
      break;
    case 0:
      monday.setDate(date - 6);
      break;
    default:
      monday.setDate(date - day + 1);
  }
  sunday = new Date(monday);
  sunday.setDate(monday.getDate() + 6);
  return {monday: monday, sunday: sunday};
}

export default {
  getFontSize,
  toWeekName,
  toWeekNameByNum,
  getWeekStartAndEnd
}
